<meta charset="UTF-8">
<style>
#f_3{
	padding:40px; 
	padding-top: 10px;
}
</style>
<div class="modal-header">
	
	<h3 class="modal-title">日期调课</h3>
</div>
<br/>

<div id="f_3">
	<form id="f_myForm">
		<div class="input-group col-md-6"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">请选择调课前日期</span> 
			<input type="text" class="form-control" name="suspendTime" placeholder="请选择调课前的日期" id="f_laydate1" />
			<span class="glyphicon glyphicon-calendar form-control-feedback" style="margin-right: 10px;"></span>
		</div>	
		<div class="input-group col-md-6"
			style="float: left; padding: 0px 10px 20px 0px;">
			<span class="input-group-addon">请选择调课后日期</span> 
			<input type="text" class="form-control" name="repairTime" placeholder="请选择调课后的日期" id="f_laydate2" />
			<span class="glyphicon glyphicon-calendar form-control-feedback" style="margin-right: 10px;"></span>
		</div>	
	</form>
</div>
<br/>
<div class="modal-footer">
	<button type="button" class="btn btn-success" data-dismiss="modal" id="f_formButton">
		<span class="glyphicon glyphicon-ok"></span>提交
	</button>
</div>

<div class="modal fade bs-example-modal-sm" id="myModal5" tabindex="-1" aria-labelledby="myModalLable">
	<div class="modal-dialog modal-lg">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h3 class="modal-title">调课冲突课程<span id="ct_title"></span></h3>
			</div>
			
			<div class="container-fluid">
				<table id="tkct" class="table table-hover table-bordered table-striped">
					<tbody></tbody>
				</table>
			</div>
			
			<div class="modal-footer">
				<button type="button" class="btn btn-danger" data-dismiss="modal">
					<span class="glyphicon glyphicon-remove"></span> 关闭
				</button>
			</div>
		</div>
	</div>
</div>
<script>
$(function(){
	//layui日期插件
	laydate.render({
	  	elem: '#f_laydate1',
	  	calendar: true,    //开启公历节日,标明节日
	  	min:minDate()
	});
	laydate.render({
	  	elem: '#f_laydate2',
	  	calendar: true,    //开启公历节日,标明节日
	  	min:minDate()
	});
});
$('#f_formButton').click(function(){
	var laydate=$("#f_laydate1").val();
	var laydatea=$("#f_laydate2").val();
	if(laydate==""){
		bootbox.alert("请选择调课前日期！");
		return false;
	}else if(laydatea==""){
		bootbox.alert("请选择调课后日期！");
		return false;
	}
	$(this).attr('disabled',true);
	var serial=$("#f_myForm").serialize();
	$.ajax({
	    type: 'post',
	    url: 'ttb/g_btn_rqtk',
	    data: serial,
	    success: function(data) {
	    	if(data.length == 0){
	    		bootbox.alert("调课成功！")
	    	}else{
	    		$("#tkct tbody").html("");
	    		var html = "<tr><td>班级</td><td>教室</td><td>老师</td><td>上课时间</td><td>星期</td><td>课程</td></tr>";
	    		$("#tkct tbody").append(html);
	    		for(var i = 0; i < data.length; i++){
	    			var x = "<tr><td>"+data[i].classes+"</td><td>"+data[i].classRoom+"</td><td>"+data[i].teacher+"</td><td>"+data[i].time+"</td><td>"+data[i].week+"</td><td>"+data[i].course+"</td></tr>";
	    			$("#tkct tbody").append(x);
	    		}
	    		$("#ct_title").html("(共"+data.length+"条)");
	    		$('#myModal5').modal("show");
	    	}
	    	/* bootbox.alert(data.msg); */
	    	$('#f_formButton').removeAttr('disabled');
	    },error:function(data){
	    	bootbox.alert(data.msg);
	    }
	});
});
//设置最小可选的日期
function minDate(){
    var now = new Date();
    return now.getFullYear()+"-" + (now.getMonth()+1) + "-" + now.getDate();
 }
</script>
